import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { Language } from "../../../../extend/language/Language";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { ImageInfo } from "../../../../com/gengine/resource/info/ImageInfo";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { BrowerUtil } from "../../../../com/gengine/utils/BrowerUtil";
import { ParamsConst } from "../../../common/global/ParamsConst";
import { GTextInput } from "../../../../com/mui/controls/GTextInput";
type int = number;
//class GetAnyGiftPanel
    
    export  class GetAnyGiftPanel /* flash.display.Sprite */
    {
        constructor(arg1: int, arg2: int)
        {
            
            this._width = arg1;
            this._height = arg2;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, this._width, this._height, this);
            ObjCreate.createBg(100, 35, 66, 66, this, ImagesConst.PackItemBg);
            this._itemIcon = new Object /* flash.display.Bitmap */();
            this._itemIcon.x = 103;
            this._itemIcon.y = 38;
            addChild(this._itemIcon);
            ObjCreate.createGTextField(Language.getString(20154), 86, 105, 100, 20, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat5));
            ObjCreate.createGTextField(Language.getString(20155), 200, 25, 300, 20, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat1));
            this._txtInput = ObjCreate.createGTextInput(200, 60, 300, 20, this);
            var loc1=ObjCreate.createGButton(Language.getString(20156), 240, 90, 80, 25, this, "ButtonSpecial");
            loc1.addEventListener(flash.events.MouseEvent.CLICK, this.onGetPackBtnClickHandler);
            var loc2=ObjCreate.createGButton(Language.getString(20157), 370, 90, 80, 25, this, "ButtonSpecial");
            loc2.addEventListener(flash.events.MouseEvent.CLICK, this.onGetCodeBtnClickHandler);
            var loc3=Language.getString(20158);
            var loc4;
            (loc4 = ObjCreate.createGTextField("", 0, 130, this._width, 40, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat1))).wordWrap = true;
            loc4.multiline = true;
            loc4.htmlText = loc3;
            LoaderManager.instance.load("14011412.jpg", this.onIconLoadedHandler);
            return;
        }

        /* internal  */onIconLoadedHandler(arg1: ImageInfo): void
        {
            if (this._itemIcon != null) 
            {
                this._itemIcon.bitmapData = arg1.bitmapData;
            }
            return;
        }

        /* internal  */onGetPackBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=this._txtInput.text;
            var loc2=parseInt(loc1.slice(4, 7));
            var loc3;
            (loc3 = new Object()).key = loc1;
            loc3.type = loc2;
            Dispatcher.dispatchEvent(new DataEvent(EventName.NoviceCardUse, loc3));
            this._txtInput.text = "";
            return;
        }

        /* internal  */onGetCodeBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            BrowerUtil.getUrl(ParamsConst.instance.getAnyGiftUrl);
            return;
        }

        /* internal */ /* var */_width: int;

        /* internal */ /* var */_height: int;

        protected /* var */_itemIcon: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_txtInput: GTextInput;
    }
